package reflect;


import java.lang.reflect.Method;

/**通过反射机制来访问类的私有成员
 * 暴力反射
 */
public class ReflectDemo7 {
    public static void main(String[] args) throws Exception {
        Class cls = Class.forName("reflect.Person");
        Object obj = cls.newInstance();
//        Method method = cls.getMethod("hehe");
//        method.invoke(obj);

        Method method = cls.getDeclaredMethod("hehe");
        method.setAccessible(true);
        method.invoke(obj);
        method.setAccessible(false);


    }
}
